<?php

namespace patterns;

class Registry
{
	function Set($name, $value, $type = false)
	{
		//print "Setting $name<br />";
		if (empty($type))
		{
			$_SESSION['registry']['generic'][$name] = $value;
		}
		else
		{
			$_SESSION['registry'][$type][$name] = $value;
		}
	}

	function Get($name, $type = false)
	{
		if (empty($type))
		{
			return $_SESSION['registry']['generic'][$name];
		}
		else
		{
			return $_SESSION['registry'][$type][$name];
		}
	}

	function WasSet($name, $type = false)
	{
		if (empty($type))
		{
			return isset($_SESSION['registry']['generic'][$name]);
		}
		else
		{
			return isset($_SESSION['registry'][$type][$name]);
		}
	}
}